/**
 * Copyright:Copyright (C) 2014-2017
 * Cpmpany:安徽东位信息科技有限责任公司
 * All Rights Reserved
 * 
 * 名称：DataLinkSubServer Demo
 * 版本：V0.0.1
 * 
 * Author:Riven
 * QQ:508620006
 * 
 * 数据采集服务监听器
 */
package com.lbssoft.gpsbd.datalink;


import com.lbssoft.datalink.util.Log;
import io.netty.channel.ChannelHandlerContext;
import io.netty.util.ReferenceCountUtil;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.lbssoft.datalink.SubServerHandler;
import com.lbssoft.datalink.model.BaseMsg;
import com.lbssoft.datalink.model.MsgType;
import com.lbssoft.datalink.model.Reply;

public class Listener extends SubServerHandler {

	 protected void messageReceived(ChannelHandlerContext channelHandlerContext, BaseMsg baseMsg) throws Exception {
		 MsgType msgType=baseMsg.getType();
	        switch (msgType){
	            //目前用户登录结果返回
	            case REPLY:{
	            	Reply result = (Reply) baseMsg;
					if(result.getCode()==0){
						Log.info("Authentication success!");
					}else{
						Log.info("Authentication failure!");
					}
	            }
	            break;

	            default:
	            	new DataHandler().Handler(msgType, baseMsg);
	            	break;
	        }
	        ReferenceCountUtil.release(msgType);


	 }

}
